/**
 * 
 */
package domain;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * @author it-equipment-selection team
 *
 */
public class UserQuery implements IQuery {

	/* (non-Javadoc)
	 * @see domain.IQuery#productQuery(java.util.Collection)
	 * @returns valid products Collection sorted by article
	 */
	public Collection productQuery(Collection products, Collection articles) {
		Collection aux = new ArrayList();
		Iterator ita = articles.iterator();
		while (ita.hasNext()){
			Article a = (Article) ita.next();
			Iterator itp = products.iterator();
			while (itp.hasNext()){
				Product p = (Product) itp.next();
				if (p.isValid() && p.getArticle().getType().compareTo(a.getType())==0){
					aux.add(p);
				}
			}
		}
		return aux;
	}

}
